package org.cytoscape.myapp.cytoscape_app_v1.internal.visual;

import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.vizmap.VisualMappingFunction;
import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyle;
import org.cytoscape.view.vizmap.VisualStyleFactory;
import org.cytoscape.view.vizmap.mappings.PassthroughMapping;

public class VisualStyleDefault {
	
	private VisualInstanceDependecies dependecies;
	private  VisualStyle style ;
	
	/**
	 * @param dependecies
	 * @param style
	 */
	public VisualStyleDefault(VisualInstanceDependecies dependecies) {
		this.dependecies = dependecies;
		this.style = dependecies.getVisualStyleFactoryServiceRef().createVisualStyle("Style Default Influence");
	}
	
	public void addPropertyToChange(VisualMappingFunction visualMapping){
		this.style.addVisualMappingFunction(visualMapping);
	}
	
	public void appyVisualStyle(){
		
		VisualStyle vs = this.getStyle();
		CyNetworkView myNetworkView = this.dependecies.getApplicationManager().getCurrentNetworkView();
		
		// Add the new style to the VisualMappingManager
		this.dependecies.getVmmServiceRef().addVisualStyle(vs);
		vs.apply(myNetworkView);
		myNetworkView.updateView();

	}
	/**
	 * @return the dependecies
	 */
	public VisualInstanceDependecies getDependecies() {
		return dependecies;
	}


	/**
	 * @param dependecies the dependecies to set
	 */
	public void setDependecies(VisualInstanceDependecies dependecies) {
		this.dependecies = dependecies;
	}


	/**
	 * @return the style
	 */
	public VisualStyle getStyle() {
		return style;
	}


	/**
	 * @param style the style to set
	 */
	public void setStyle(VisualStyle style) {
		this.style = style;
	}

}
